/*	Copyright 2008 Jacquemin Valentin

   Licensed under the Apache License, Version 2.0 (the "License");
   you may not use this file except in compliance with the License.
   You may obtain a copy of the License at

       http://www.apache.org/licenses/LICENSE-2.0

   Unless required by applicable law or agreed to in writing, software
   distributed under the License is distributed on an "AS IS" BASIS,
   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   See the License for the specific language governing permissions and
   limitations under the License.
 */
package org.poxd;

import static org.poxd.tools.ConfigUtils.FS;

import java.awt.Toolkit;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import java.io.IOException;
import java.sql.SQLException;

import javax.swing.JFrame;
import javax.swing.JMenu;
import javax.swing.JMenuBar;
import javax.swing.UIManager;
import javax.swing.UnsupportedLookAndFeelException;

import org.apache.log4j.Logger;
import org.hibernate.HibernateException;
import org.poxd.persistance.SessionService;
import org.poxd.tools.ConfigUtils;
import org.poxd.ui.MainPane;

import com.jgoodies.looks.plastic.PlasticXPLookAndFeel;

/**
 * @author Valentin Jacquemin
 *
 */
public class Sniwe {

	public static final String APP_NAME = "Sniwe";

	public static final String USER_HOME = System.getProperty("user.home");

	public static final String SNIWE_DIR = USER_HOME + FS + "." + APP_NAME;

	private static final Logger log = Logger.getLogger(Sniwe.class);

	/**
	 * @param args
	 * @throws ClassNotFoundException
	 * @throws IOException
	 * @throws SQLException
	 * @throws IllegalAccessException 
	 * @throws InstantiationException 
	 */
	public static void main(String[] args) throws ClassNotFoundException,
			IOException, SQLException, InstantiationException, IllegalAccessException {
		ConfigUtils.createUserDir();
		ConfigUtils.initDB();
		log.debug("Initialisation done");

		 try {
			UIManager.setLookAndFeel(new PlasticXPLookAndFeel());
		} catch (UnsupportedLookAndFeelException e) {
			e.printStackTrace();
		}

		final JFrame f = new JFrame("Sniwe") {
			private static final long serialVersionUID = 1L;
			{
				setRootPane(new MainPane(this));
			}
		};
		f.setLocationRelativeTo(null);
		f.setSize(860, 680);
		f.setLocation((int) Toolkit.getDefaultToolkit().getScreenSize()
				.getWidth()
				/ 2 - f.getWidth() / 2, (int) Toolkit.getDefaultToolkit()
				.getScreenSize().getHeight()
				/ 2 - f.getHeight() / 2);
		
		
		f.setVisible(true);
	}

}
